/* -*-C++-*- */
/* A list of statements seperated by seperator ';' */

print "Test for stmt_list\n"
print "------------------\n"
a=1;b=2;a=1;b=2;

/****************************************************
 Leave the previous comment in a single line.  That 
 will ensure that single-line comments as well as
 multiple line comments are tested.  This comments 
 itself is a test of lexical analysis of the input 
 which spans more than one line.

 Following is a test for compund statement
*****************************************************/
{a=1;b=2;}

/****************************************************
 A list of simple and compund statements 
******************************************************/
{a};{b};a;b;

/*****************************************************
 A compund statement with embedded NEWLINES 
******************************************************/
print "Test for stmt_list with embedded NEWLINES\n"
print "-----------------------------------------\n"
{

a=1;


b=2;


c=3;


}

/*************************************************** 
   A compound statement made of simple and other
   compund statements seperated either by a NEWLINE
   or a seperator.  
****************************************************/
{
{a=1;}
{b=2;}
{b=2;}
1;2;3;{b=2;}
1;2;3;{b=2;};1;2;3;



{1;2;3};{b=2;};1;2;3;


{1;2;

}


}

/*****************************************************
 Test for assignment as a function argument 
******************************************************/
print "sin(1.5)=",sin(1.5),"\n"
/* print "sin(a=1.5)=",sin(a=1.5)," a=",a,"\n"*/
/*************************************************
   Just a compund statement, but with NEWLINES
   after and before the starting and closing
   compund statement delimiters ('{' and '}')
**************************************************/
{
{a=1;b=2;}
}

/**********************************************************
 A test to test the print command with strings and numbers 
***********************************************************/
print "this is a test to print a number \"one\" with precision %8.3f ",a%8.3f,"\n"


/**************************************************
 Tests for if statement 
***************************************************/
print "Test for various forms of for-statements\n"
print "----------------------------------------\n"
if (a) 
  { print "a=1",a,"\n";} else 
  { print "Not a\n";}

a=1.1
if (a) 
  { if (a>1) {print "a>1",a,"\n";} else {print "a<=1",a,"\n";} } else 
  { print "a=0\n";}

if (a) a; else b=10;
print "b=",b,"\n"
a=0;
if (a) a; else b=10;;print "b=",b,"\n"

/***************************************************
Test for while-statement 
****************************************************/
print "Test for while-statement\n"
print "------------------------\n"
a=10;while(a>0) {
 if (a>5) a;
 a=a-1;
 if (a<5) -a;
}

/***************************************************
 Test for for-statement on a single line 
****************************************************/
print "Test for for-statement\n"
print "----------------------\n"
for(b=0,a=0;a<10;a=a+1,b=a) print "a=",a%f,"\tb=",b%f,"\n";

/***************************************************
 Test for for-statement not on a single line 
****************************************************/
print "Test for for-statement\n"
print "----------------------\n"
for(b=0,a=0;a<10;a=a+1,b=a) 
 print "a=",a%f,"\tb=",b%f,"\n";

/****************************************************
 Changing the FMT of a variable 
*****************************************************/
a=1;
print "Before change of FMT a = ",a,"\n"

a.=%E

print "After change of FMT a = ",a,"\n"
/****************************************************
   Tests for break statement
****************************************************/
b=0;

print "Test for break statement\n";
print "------------------------\n"
while (a)
{
  for(a=0;a<10;a=a+1) 
   {
     if (a>5) break;
   }
  b=b+1;
  print "Value of b = ",b,"\n";
  if (b>=5)    break;
}

print "Value of a = ",a,"\n";

while(a<100)
{
  a.=%E;
 for(a=0%E;a<100;a=a+1) 

  {
   if (a>=50) break; 
  }

 print "a=";
 print a,"\n"; 

 break;
}

f(x)
{
  auto y;
  print "From f: Arg=",x,"\n";
  x.=%E;
  x;
  y=10;
  print "From f: Auto var y=",y,"\n";
  return y;
}

ff(x) {auto t;print "From ff: Arg=",x,"\n";t=(x+10);t.=%f;return t%f;}

p(func f,x)
{
  auto t;
  print "From p: Arg=",x,"\n";
  t=f(x);
  print "From p: Function called as a arg list of print statement. Result = ",f(x),"\n";
  print "From p: Value of function call in an auto. var. = ",t,"\n";
}

pp(proc p, func f,x)
{
  print "From pp: Arg=",x,"\n";
  p(f,x)
}

print "\nTesting f(10): \n";
print "--------------\n"
f(10);
print "\nTesting ff(10): \n";
print "--------------\n"
ff(10);
print "\nTesting p(ff,10): \n";
print "-----------------\n"
p(ff,10);
print "\nTesting pp(p,ff,10): \n";
print "--------------------\n"
pp(p,ff,10);

inf()
{
  print "Test for an infinite for-loop.  Do a Ctrl-C if you want to do something useful!\n";
  auto i;
  for(i=0;i> -1;i=i+1);
}

infw()
{
  print "Test for an infinite while-loop.  Do a Ctrl-C if you want to do something useful!\n";
  auto i,j;
  j=i=1;
  while(i) {f(i);i=i+2;}
}

/*------------------------------------------------------------------------*/
